package com.xuerhua.yxt.controller.sys.student;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xuerhua.yxt.common.RspResult;
import com.xuerhua.yxt.common.enums.Status;
import com.xuerhua.yxt.controller.BaseController;
import com.xuerhua.yxt.model.Grid;
import com.xuerhua.yxt.model.StudentSchoolPrize;
import com.xuerhua.yxt.page.Page;
import com.xuerhua.yxt.reqVo.BasePageQueryVO;
import com.xuerhua.yxt.service.IStudentSchoolPrizeService;

@RequestMapping("sys/student/schoolAward")
@Controller
public class SysStudentSchoolAward extends BaseController {

	@Autowired
	private IStudentSchoolPrizeService studentSchoolPrizeService;
	
	@RequestMapping(value = {"","/"})
	public String Index() {
		return "sys/student/schoolAward";
	}
	
	@RequestMapping("pageQuery")
	@ResponseBody Object pageQuery(BasePageQueryVO vo){
		try {
			Page<StudentSchoolPrize> page = new Page<>();
			page.setPageNo(vo.getPage());
			page.setPageSize(vo.getRows());
			page.setParams(vo);
			List<StudentSchoolPrize> list = studentSchoolPrizeService.selectListByPage(page);
			Grid grid = new Grid();
			grid.setRows(list);
			grid.setTotal(page.getTotalRecord());
			return grid;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	//TODO 这个不知道哪里有的哦
	@RequestMapping("addUpdate")
	@ResponseBody Object addUpdate(StudentSchoolPrize record) {
		try {
			if(record.getId() == null) {
				studentSchoolPrizeService.updateByPrimaryKeySelective(record);
			}else {
				studentSchoolPrizeService.insertSelective(record);
			}
			return new RspResult(Status.SUCCESS);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new RspResult(Status.FAIL);
	}
	
}
